import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		openid:'',
		
		// 自定义tabbar
		footer_nav: [{
				name: '首页',
				name_code: 'home',
				icon: '/static/footer_icon/a2.png',
				select_icon: '/static/footer_icon/a1.png'
			},
			{
				name: '发布',
				name_code: 'publish',
				icon: '/static/footer_icon/f2.png',
				select_icon: '/static/footer_icon/f1.png'
			}
		],
		now_page_index: 0,
	},
	mutations: {
		login(state, provider) {
			console.log(provider.openid)
			state.openid = provider.openid;
			// console.log(state.openid)
			// uni.setStorage({ //缓存用户登陆状态
			// 	key: 'userInfo',
			// 	data: provider
			// })
		},
		logout(state) {
			state.hasLogin = false;
			state.userInfo = {};
			uni.removeStorage({
				key: 'userInfo'
			})
		},
		saveTypeId(state, provider){
			state.typeid = provider
		},
		saveHasLogin(state, provider){
			state.hasLogin = true;
		},
		
		change_page(state, index) {
			state.now_page_index = index;
		}
	},
	actions: {

	}
})
export default store
